package com.orion.service;

import com.orion.entity.InnerTrans;
import com.orion.entity.Trans;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author Administrator
 * @date 2021/10/19
 */
@Service
@FeignClient("provider")
public interface TestService {

    //------------------------------  get  start -------------------------------------

    /*
     *  对于GET
     *
     *  @RequestParam 和 @PathVariable
     *  参数是基本的类型，必须加上别名，括号里面的描述
     *
     *  参数是map可以不用，map的话使用@RequestParam 和 @SpringQueryMap 都可以
     *
     *  多参数不建议用map，可读性差，用@SpringQueryMap
     *
     *  多参数也可以用bean来接收，复合的bean会有问题(即bean里面有别的bean参数)
     *  简单参数的bean就没问题
     *
     */
    @GetMapping("/test/getWithInt")
    Integer getWithInt(@RequestParam("i") Integer i);

    @GetMapping("/test/getWithDouble")
    Double getWithDouble(@RequestParam("d") Double d);

    @GetMapping("/test/getWithString")
    String getWithString(@RequestParam("str") String s);

    @GetMapping("/test/getWithPvInt/{id}")
    Integer getWithPvInt(@PathVariable("id") Integer id);

    @GetMapping("/test/getWithPvStr/{code}")
    String getWithPvStr(@PathVariable("code") String code);

    @GetMapping("/test/getWithMap")
    //Map getWithMap(@RequestParam("m") Map m);
    Map getWithMap(@SpringQueryMap Map m);

    //复杂类型接收失败（bean 嵌 bean）
    @GetMapping("/test/getWithBean")
    Trans getWithBean(@SpringQueryMap Trans t);

    @GetMapping("/test/getWithSimpleBean")
    InnerTrans getWithSimpleBean(@SpringQueryMap InnerTrans t);

    @GetMapping("/test/getBean")
    Trans getBean();

    //-------------------------------**- get  end -**-------------------------------------

    //---------------------------------  post  start -------------------------------------
    @PostMapping("/test/postWithInt")
    Integer postWithInt(@RequestParam("i") Integer i);

    @PostMapping("/test/postWithDouble")
    Double postWithDouble(@RequestParam("d") Double d);

    @PostMapping("/test/postWithString")
    String postWithString(@RequestParam("s") String s);

    @PostMapping("/test/postWithMap")
    Map postWithMap(Map m);

    @PostMapping("/test/postWithList")
    List<Trans> postWithList(List l);

    @PostMapping("/test/postWithBean")
    Trans postWithBean(Trans t);

    @PostMapping("/test/postWithSimpleBean")
    InnerTrans postWithSimpleBean(InnerTrans t);


    //------------------------------**-  post  start -**-----------------------------------


    @PutMapping("/test/putBean")
    Trans putBean(Trans trans);

    @DeleteMapping("/test/deleteInter")
    String deleteInter(Integer i);
}
